<template>
    
    <a-modal
      :title="'选择供应商'"
      :visible="true"
      width="60%"
      :footer="null"
      @cancel="reset"
    >
      <div class="main">
        <a-card>
          <a-table
            bordered
            :row-selection="{ selectedRowKeys: selectedRowKeys,selectedRows:selectedRows, onChange: onSelectChange,type:'radio' }"
            :columns="columns"
            :loading="loading"
            :data-source="dataList"
          />
  
        </a-card>
      </div>
  
    </a-modal>
  </template>
  
  <script>
  import { postAction } from '@/api/manage'
  const columns = [
  {
    title: '供应商',
    width: 100,
    dataIndex: 'supplyName',
  },
  {
    title: '供应商编号',
    width: 150,
    dataIndex: 'supplyCode'
  },
  {
    title: '税率',
    width: 100,
    dataIndex: 'taxRate'
  },
  {
    title: '采购含税价',
    width: 150,
    dataIndex: 'purchaseTaxTratePrice'
  },
  ]
  export default {
    components: {},
  
    props: {
      content: {
        type: Object,
        default: null
      }
    },
  
    data() {
      return {
        urlKey: 'basemgt-material/',
        accPriceCode:'',
        columns,
        loading: false,
        brand: [],
        accountInfo: {},
        form: this.$form.createForm(this),
        dataList: [],
        selectedRowKeys: [],
        selectedRows: [],
        password: '',
        groupId: '',
        roleList: [],
        roleIdList:[],
        showTable: false
      }
    },
  
    created() {
      const { content } = this.$props
      if (content.accPriceCode) {
        this.accPriceCode = content.accPriceCode
        this.getDetail()
      }else{
        this.$message.warning('无物料代码！')
      }
    },
    mounted() {},
    computed: {
      jobNumber() {
        return this.$store.getters.userInfo.workNo || ''
      }
    },
    methods: {
      handleSubmit(e) {
        e.preventDefault()
        this.loadData()
      },
      reset() {
        this.$emit('closeSupply')
      },
      onSelectChange(selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
        console.log(this.selectedRows)
        this.$emit('closeSupply',this.selectedRows[0])
        
      },
      getDetail() {
        this.loading = true
        const params = {
          accPriceCode: this.accPriceCode
        }
        try {
          postAction(`${this.urlKey}accessories/price/list`, params).then(res => {
            if (res.code == 200) {
              this.dataList = res.data
            } else {
              this.$message.warning(res.msg)
            }
          })
        } catch (error) {
          this.$message.warning('获取列表失败！')
        }finally{
          this.loading = false
        }
      },
      
    }
  }
  </script>
